const forEach = (arr, visitor) => {
    this.arr = arr
    for (let i = 0; i < this.arr.length; i++) {
        visitor(arr[i],i)
    }
}
class Foreach {
    constructor() {
        this.foreach = forEach
    }
}
var fe = new Foreach()
var arr = [1,3,5,7,8]
var v1 = function(elem,index){
    console.log(index+":"+elem)
}
fe.foreach(arr,v1)